﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1.Forms
{
    public partial class FormMain2 : Form
    {
        public FormMain2()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }
        public string[] departmentNameList = { "财务部", "产品部", "销售部", "生产部" };
        private void FormMain2_Load(object sender, EventArgs e)
        {
            for (int i = 0; i < 4; i++)
            {
                this.comboBox1.Items.Add(departmentNameList[i]);
            }
            
            //默认选择index = 1
            this.comboBox1.SelectedIndex = 1;

            for (int i = 0; i < 4; i++)
            {
                this.comboBox2.Items.Add(departmentNameList[i]);
            }
            //默认选择Index = 1
            this.comboBox2.SelectedIndex = 1;

            for (int i = 0; i < 4; i++)
            {
                this.listBox1.Items.Add(departmentNameList[i]);
            }
            //默认选择Index = 1
            this.listBox1.SelectedIndex = 1;


        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string mess = comboBox1.SelectedItem.ToString();
            #region 不需要比较是否存在
            //comboBox2.SelectedItem = comboBox2.Items.Contains(mess) ? mess : comboBox2.SelectedItem;

            //listBox1.SelectedItem = listBox1.Items.Contains(mess) ? mess : listBox1.SelectedItem;
            #endregion

            comboBox2.SelectedItem = mess;
            listBox1.SelectedItem = mess;

            textBox1.Text = mess;

        }

        private void label3_Click(object sender, EventArgs e)
        {

        }
    }
}
